<div class="breadcrumb d-flex align-items-center px-3 js-scroll">
    <div class="btn btn-icon me-4 js-back" aria-label="返回" role="button" tabindex="0">
        <i class="iconfont icon-left-arrow fs-20"></i>
    </div>
    <h2 class="w-100 fs-18 hand js-top"><?= $page_title ?? ''; ?></h2>
    <div class="ms-auto">
        <!-- <div class="search">
            <i class="iconfont icon-search"></i>
            <input class="form-control search-input" type="text" placeholder="搜索标签">
        </div> -->
        <div class="btn btn-icon" aria-label="创建标签" role="button" tabindex="0">
            <i class="iconfont icon-add fs-20"></i>
        </div>
    </div>
</div>

<div class="m-3">
    <h2 class="fs-18">置顶标签</h2>
    <div class="p-5 text-center text-muted border-bottom">
        置顶你喜欢的标签，然后就能快速访问他们。
    </div>
</div>

<ul class="card-list list-unstyled">
<?php if(!$tags[0]): ?>
    <div class="placeholder fs-28">
        <p>暂时还没人建立标签</p>
        <p class="mt-4">
            <a href="" class="btn btn-lg btn-secondary rounded-pill px-4"><b>建立一个标签</b></a>
        </p>
    </div>
<?php else: ?>
    <?php foreach ($tags[0] as $tag): ?>
    <li class="d-flex cursor-pointer js-tap" data-href="/tag/list/<?= $tag->id ?>">
        <img class="avatar avatar-lg me-3" src="/img/avatar.jpg" alt="">
        <div>
            <strong><?= $tag->name ?></strong>
            <p class="text-muted fs-15"><?= $tag->intro ?></p>
        </div>
        <div class="ms-auto">
            <a href="###" class="btn btn-icon" data-bs-toggle="tooltip" data-bs-title="置顶">
                <i class="iconfont icon-thumbtack fs-20"></i>
            </a>
        </div>
    </li>
    <?php endforeach ?>
<?php endif ?>
</ul>

<?php if($tags[1]->totalRows !== 0): ?>
<nav aria-label="Page navigation">
    <ul class="pagination justify-content-center p-3">
        <li class="page-item"><a class="page-link" href="<?= $tags[1]->prevPage;?>"><span aria-hidden="true">&lsaquo;</span></a></li>
<?php foreach($tags[1]->listPage as $k=>$v): ?>
    <?php if($k == $tags[1]->currentPage): ?>
        <li class="page-item"><a class="page-link active" href="<?= $v ?>"><?= $k ?></a></li>
    <?php else: ?>
        <li class="page-item"><a class="page-link" href="<?= $v ?>"><?= $k ?></a></li>
    <?php endif ?>
<?php endforeach ?>
        <li class="page-item"><a class="page-link" href="<?= $tags[1]->nextPage;?>"><span aria-hidden="true">&rsaquo;</span></a></li>
    </ul>
</nav>
<?php endif ?>


<script>
// 确保DOM加载完毕
document.addEventListener('DOMContentLoaded', () => {
    highlightActiveLink('tag');
});
</script>